package com.chenxin.interact.api;

import com.chenxin.common.core.domain.AjaxResult;
import com.chenxin.common.utils.uuid.UUID;
import com.chenxin.framework.web.service.SysLoginService;
import com.chenxin.interact.domain.dto.TokenDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class WmsAPI {
    @Autowired
    private SysLoginService loginService;

    @PostMapping("/token-req")
    public AjaxResult TokenRequest(@RequestBody TokenDTO dto) {
        AjaxResult ajaxResult = AjaxResult.success(0, "认证通过!");
        // 获取UUID
        UUID uuid = UUID.fastUUID();
        // 生成令牌
        String token = loginService.login(dto.getUsername(), dto.getPassword(), "mes",
                uuid.toString());
        ajaxResult.put("token", token);
        return ajaxResult;
    }
}
